package com.sx.web.player.servlet;

import com.sx.dao.PlayerfoDAO;
import com.sx.domain.Player;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.sql.SQLException;

@WebServlet("/delPlayerServlet")
public class DelPlayerServlet extends HttpServlet {
  protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    this.doGet(request, response);
  }

  protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
    request.setCharacterEncoding("utf-8");//设置请求的编码
    response.setContentType("text/html;charset=utf-8");//设置响应的编码
    PrintWriter out=response.getWriter();//获取响应字节打印流
    String id = request.getParameter("id");
    try {
      PlayerfoDAO.delPlayerById(id);
    } catch (SQLException throwables) {
      throwables.printStackTrace();
    }
    out.print("ok");
  }
}
